<template>
  <div id="seteventdetails">
    <fieldset class="layui-elem-field layui-field-title">
      <legend>模块标题</legend>
      <div class="layui-field-box">
        <el-input v-model="moddata[index].config.title" placeholder="请输入模块标题"></el-input>
      </div>
    </fieldset>
    <fieldset class="layui-elem-field layui-field-title">
      <legend>是否显示</legend>
      <div class="layui-field-box">
        <el-switch v-model="moddata[index].visible" on-color="#13ce66" off-color="#ff4949">
        </el-switch>
      </div>
    </fieldset>
    <fieldset class="layui-elem-field layui-field-title">
      <legend>模块图标</legend>
      <div class="layui-field-box">
        <div class="icon-box">
          <i :class="['iconfont','iconset',moddata[index].config.icon?moddata[index].config.icon:moddata[index].defaultIcon]"></i>
        </div>
        <el-button @click="choseIcon(true)" type="primary">选择图标</el-button>
      </div>
    </fieldset>
    <fieldset class="layui-elem-field layui-field-title">
      <legend>图标颜色</legend>
      <div class="layui-field-box">
        <el-color-picker v-model="color1" @change="changefc"></el-color-picker>
      </div>
    </fieldset>
    <fieldset class="layui-elem-field layui-field-title" v-if="pageconfig.theme == 'tradition'">
      <legend>背景颜色</legend>
      <div class="layui-field-box">
        <el-color-picker v-model="color2" @change="changefc"></el-color-picker>
      </div>
    </fieldset>
    <el-button @click="save" type="primary">保存</el-button>
    <el-button @click="cancel">取消</el-button>
    <transition name="fade">
      <div class="callsponsor" v-show="choseicon">
        <transition name="move">
          <div class="box" v-show="choseicon">
            <p>图标库</p>
            <i class="el-message-box__close el-icon-close close" @click="choseIcon(false)"></i>
            <div class="content">
              <div :class="['icon-box',nowIcon == iconitem ? 'active':'']" v-for="iconitem in iconlist" @click="clickicon(iconitem)">
                <i :class="['iconfont','iconset',iconitem]"></i>
              </div>
            </div>
            <div class="bottombox">
              <el-button @click="choseIcon(false)">取消</el-button>
              <el-button @click="confirm" type="primary">确定</el-button>
            </div>
          </div>
        </transition>
      </div>
    </transition>
  </div>
</template>

<script>
  export default {
    props: ["moddata", "index", "pageconfig"],
    data: function () {
      return {
        input: this.moddata[this.index].config.title,
        color1: this.moddata[this.index].config.color,
        color2: this.moddata[this.index].config.backgroundColor,
        choseicon: false,
        nowIcon: this.moddata[this.index].config.icon,
        iconlist: [
          "icon-activity_fill",
          "icon-coordinates_fill",
          "icon-group_fill",
          "icon-people_fill",
          "icon-shijiandidianiconfontshiyongzhinan",
          "icon-icon-system-fi-ticket",
          "icon-xiangqing",
          "icon-addition_fill",
          "icon-barrage_fill",
          "icon-brush_fill",
          "icon-businesscard_fill",
          "icon-camera_fill",
          "icon-clock_fill",
          "icon-collection_fill",
          "icon-marketing_fill",
          "icon-financial_fill",
          "icon-computer_fill",
          "icon-customerservice_fill",
          "icon-dynamic_fill",
          "icon-feedback_fill",
          "icon-flag_fill",
          "icon-flashlight_fill",
          "icon-homepage_fill",
          "icon-integral_fill",
          "icon-interactive_fill",
          "icon-like_fill",
          "icon-live_fill",
          "icon-lock_fill",
          "icon-redpacket_fill",
          "icon-remind_fill",
          "icon-systemprompt_fill",
          "icon-task_fill",
          "icon-time_fill",
          "icon-unlock_fill",
          "icon-video_fill",
          "icon-warning_fill",
          "icon-workbench_fill",
          "icon-qianniu"
        ]
      }
    },
    watch: {
      index() {
        this.color2 = this.moddata[this.index].config.backgroundColor
      }
    },
    methods: {
      changefc: function () {
        this.moddata[this.index].config.backgroundColor = this.color2;
        this.moddata[this.index].config.color = this.color1;
      },
      cancel: function () {
        this.$emit('setdone', 2);
      },
      save: function () {
        this.$emit('setdone', 1);
      },
      choseIcon(bol) {
        if (bol) {
          this.nowIcon = this.moddata[this.index].config.icon;
        }
        this.choseicon = bol
      },
      clickicon(a) {
        this.nowIcon = a;
      },
      confirm() {
        this.moddata[this.index].config.icon = this.nowIcon;
        this.choseicon = false;
      }
    }
  }
</script>

<style scoped lang="less">
  .icon-box {
    width: 34px;
    height: 34px;
    border: 1px solid #ccc;
    display: inline-block;
    vertical-align: middle; // box-sizing: border-box;
    .iconset {
      font-size: 34px;
      line-height: 34px;
      color: #666;
    }
  }

  .icon-box.active {
    border: 1px solid #20a0ff;
  }

  .callsponsor {
    background: rgba(0, 0, 0, .5);
    transition: width 0.5s;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    z-index: 2001;
    .box {
      text-align: left;
      display: inline-block;
      vertical-align: middle;
      background-color: #fff;
      width: 550px;
      border-radius: 3px;
      font-size: 16px;
      overflow: hidden;
      -webkit-backface-visibility: hidden;
      backface-visibility: hidden;
      background: #fff;
      position: relative;
      p {
        padding: 20px 20px 0;
      }
      .content {
        padding: 20px;
        .icon-box {
          margin: 5px;
          .iconset {
            transition: all .4s;
          }
          .iconset:hover {
            transform: translateY(-2%);
            box-shadow: 1px 4px 10px 2px #CCC;
            -webkit-box-shadow: 1px 4px 10px 2px #CCC;
            -moz-box-shadow: 1px 4px 10px 2px #CCC;
          }
        }
      }
      .bottombox {
        padding: 10px 20px 15px;
        text-align: right;
      }
    }
    .close {
      position: absolute;
      top: 19px;
      right: 20px;
      font-size: 13px;
      color: #999;
    }
  }

  .callsponsor:after {
    content: "";
    display: inline-block;
    height: 100%;
    width: 0;
    vertical-align: middle;
  }

  .fade-enter-active,
  .fade-leave-active,
  .move-enter-active,
  .move-leave-active {
    transition: all .4s
  }

  .fade-enter,
  .fade-leave-to {
    opacity: 0
  }

  .move-enter,
  .move-leave-to {
    transform: translateY(-20px);
  }
</style>